Database access and tools

The class will have access to a MySQL server here at Dartmouth for Lab 2 and a MongoDB Atlas cluster in the Cloud for Labs 3 and 4, respectively. Access to the Dartmouth MySQL server requires the use of the Dartmouth VPN for access. Access to the MongoDB server only requires Internet access. Both labs can be completed using these shared resources.

Database access

Userids and passwords for accessing our Dartmouth MySQL Server will be distributed early in the term once enrollment has settled down.

Instructions for userids and passwords for accessing the MongoDB Atlas cloud service will be distributed at a later date.

Step 1: MySQL and MongoDB

DB Tools

These are tools that you will need whether working with Databases in the cloud or locally. Follow the instructions for your platform here

Local installation of database servers (optional)

It is not required, but if you are experienced at installing and configuring software, you may choose to install MySQL locally for your own convenience. Follow the instructions for your platform here

Installing MongoDB locally is not recommended.


⚠️ Note: If you develop your software lab assignments on your laptop, remember that we test your labs on the Babylon machines at Thayer and the databases used are the MySQL database provided by Dartmouth and the MongoDB database provided by ATLAS in the cloud. Thus, you must ensure that your lab submissions run properly on the Babylon machines.


Step 2: Miniconda (optional if you are very experienced with Python)

Miniconda is a free minimal installer for conda and Python. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. We recommend its use as it can help prevent python packages from interfering with each other. Instructions are provided below for for installing on Windows, MacOS, and Linux.

Windows

  1. Download the installer in the following link .
  2. Double-click the .exe file.
  3. Follow the instructions on the screen.
  4. Check the checkbox to add Anaconda to your environment Path and click Install.
  5. Test your installation. In your terminal window or Anaconda Prompt, run the command run the command
$ conda  list
# packages in environment at /Users/ccpalmer/opt/miniconda3:
#
# Name                    Version                   Build  Channel
brotlipy                  0.7.0           py39h9ed2024_1003
ca-certificates           2022.3.29            hecd8cb5_1
certifi                   2021.10.8        py39hecd8cb5_2
cffi                      1.15.0           py39hc55c11b_1
charset-normalizer        2.0.4              pyhd3eb1b0_0
colorama                  0.4.4              pyhd3eb1b0_0
conda                     4.12.0           py39hecd8cb5_0
conda-content-trust       0.1.1              pyhd3eb1b0_0
conda-package-handling    1.8.1            py39hca72f7f_0
cryptography              36.0.0           py39hf6deb26_0
...

A list of installed packages appears if it has been installed correctly.

Continue with Step 3.

Mac

  1. If you have an Intel-based Mac, download the package at link . If you have a M1 or M2-based Mac, download this package instead .
  2. Open the downloaded file.
  3. Follow the instructions on the screen.
  4. Check the checkbox to add Anaconda to your environment Path and click Install.
  5. Test your installation. In your terminal window or Anaconda Prompt, run the command run the command
$ conda  list
# packages in environment at /Users/ccpalmer/opt/miniconda3:
#
# Name                    Version                   Build  Channel
brotlipy                  0.7.0           py39h9ed2024_1003
ca-certificates           2022.3.29            hecd8cb5_1
certifi                   2021.10.8        py39hecd8cb5_2
cffi                      1.15.0           py39hc55c11b_1
charset-normalizer        2.0.4              pyhd3eb1b0_0
colorama                  0.4.4              pyhd3eb1b0_0
conda                     4.12.0           py39hecd8cb5_0
conda-content-trust       0.1.1              pyhd3eb1b0_0
conda-package-handling    1.8.1            py39hca72f7f_0
cryptography              36.0.0           py39hf6deb26_0
...

A list of installed packages appears if it has been installed correctly.

Continue with Step 3.

Linux

  1. Download the installer in the following link .
  2. In your terminal window, run:

    bash Miniconda3-latest-Linux-x86_64.sh
    
  3. Follow the prompts on the installer screens. If you are unsure about any setting, accept the defaults. You can change them later.
  4. Make sure to add Environment variable for Miniconda (it can be set up in the installer).
  5. Reload Shell: To start using Anaconda without logging out while maintaining the state of the Current Shell or terminal; reload the bash, in simple words reload your profile without restarting or logging out ofthe session.

    source ~/.bashrc
    
  6. Test your installation. In your terminal window or Anaconda Prompt, run the command
$ conda  list
# packages in environment at /Users/ccpalmer/opt/miniconda3:
#
# Name                    Version                   Build  Channel
brotlipy                  0.7.0           py39h9ed2024_1003
ca-certificates           2022.3.29            hecd8cb5_1
certifi                   2021.10.8        py39hecd8cb5_2
cffi                      1.15.0           py39hc55c11b_1
charset-normalizer        2.0.4              pyhd3eb1b0_0
colorama                  0.4.4              pyhd3eb1b0_0
conda                     4.12.0           py39hecd8cb5_0
conda-content-trust       0.1.1              pyhd3eb1b0_0
conda-package-handling    1.8.1            py39hca72f7f_0
cryptography              36.0.0           py39hf6deb26_0
...

A list of installed packages appears if it has been installed correctly.



Step 3: Setting up your Python environment

Finish the python setup by following the next instructions for Windows or for MacOS and Linux.

Python setup for Windows

  1. Run Anaconda cmd prompt (miniconda3) on Mac and Linux, or Anaconda Powershell prompt (miniconda3) in your Windows apps. IMPORTANT: All conda and pip commands will be executed at one of these two prompts. Note: If you are a user of the Anaconda Python development environment, you probably know that Anaconda likes to keep its executables separate from the general system executables. This makes a lot of sense. Chances are that your operating system has a default Python installation somewhere, and Anaconda wants to avoid library clashes.
  2. Create your own environment for databases with most recent stable python version:
$ conda create -n db python==3.9
  1. Activate your new environment:
$ conda activate db
  1. Install the following packages:
# install jupyter lab
$ pip install jupyterlab

# install pandas
$ pip install pandas

# database manipulation tool for python.
$ conda install -n db -c anaconda sqlalchemy

# ipython/notebook sql plugin
$ conda install -n db -c conda-forge ipython-sql

# mysql-connector-python
$ conda install -n db -c anaconda mysql-connector-python

# python-mongo plugin
$ pip install pymongo

You have completed Lab 0.


Python setup for Mac and Linux

  1. Create your own environment for databases with last stable python version:
$ conda create -n db python==3.9
  1. Activate your new environment:
$ conda activate db
  1. Install the following packages:
# install jupyter lab
$ pip install jupyterlab

# install pandas
$ pip install pandas

# database manipulation tool for python.
$ conda install -n db -c anaconda sqlalchemy

# ipython/notebook sql plugin
$ conda install -n db -c conda-forge ipython-sql

$ conda install -n db -c anaconda mysql-connector-python

# python-mongo plugin
$ pip install pymongo

You have completed Lab 0.